package com.daxiasoftware.xxx.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
import org.springframework.stereotype.Component;

@Component
public class PasswordEncoder extends Md5PasswordEncoder {
	private static Logger logger = LoggerFactory.getLogger(PasswordEncoder.class);

	@Value("${biz.salt}")
	private String salt;
	
	@Override
	public String encodePassword(String rawPass, Object notUserSalt) {
		logger.debug("salt: {}", salt);
		logger.debug("encodePassword, raw: {}, result: {}", rawPass, super.encodePassword(rawPass, salt));

		return super.encodePassword(rawPass, salt);
	}
	
	public static void main(String[] args) throws Exception {
		System.out.println(new PasswordEncoder().encodePassword("333333", ""));
	}
	
}
